﻿@using EC.Entity.Response.Role
@using EC.Entity.Enum

@model EC.Entity.PagedList<RoleQueryResponse>

<div class="data-body data-scroll">
    <div class="data-view">
        <div class="data-div-view table-responsive">
            <table class="table table-hover table-striped table-bordered">
                <thead>
                    <tr>
                        <th class="t_l">角色名称</th>
                        <th width="100">状态</th>
                        <th width="165">操作</th>
                    </tr>
                </thead>
                <tbody>
                    @if (Model != null && Model.TData != null && Model.TData.Any())
                    {
                        foreach (var item in (List<RoleQueryResponse>)Model.TData)
                        {
                            <tr>
                                <td class="t_l">@(item.Name)</td>
                                <td width="100">
                                    @(item.Status == (sbyte)RoleStatus.启用 ? Html.Raw("<span class='green bold'>启用</span>") : Html.Raw("<span class='red bold'>禁用</span>"))
                                </td>
                                <td width="165">
                                    @if (item.Status == (sbyte)RoleStatus.启用)
                                    {
                                        <a class="btn btn-danger btn-xs" data-confirm="确定要禁用该角色？" data-href="/Auth/UpdateRoleStatus?id=@(item.Id)&status=@((sbyte)RoleStatus.禁用)">禁用</a>
                                    }
                                    else
                                    {
                                        <a class="btn btn-primary btn-xs" data-confirm="确定要启用该角色？" data-href="/Auth/UpdateRoleStatus?id=@(item.Id)&status=@((sbyte)RoleStatus.启用)">启用</a>
                                    }
                                    <button type="button" class="btn btn-default btn-xs" data-modal="/Auth/RoleAddOrEdit/@(item.Id)" data-title="编辑 - @(item.Name)" data-width="452" data-height="400">
                                        <span class="glyphicon glyphicon-edit"></span> 编辑
                                    </button>
                                    <a class="btn btn-danger btn-xs" data-confirm='@(item.Name) <br>确定要<span class="red">删除</span>该角色？' data-href="/Role/Delete?id=@(item.Id)"><span class="glyphicon glyphicon-trash"></span> 刪除</a>
                                </td>
                            </tr>
                        }
                    }
                    else
                    {
                        <tr>
                            <td colspan="3" class="t_c">暂无记录</td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>
<!-- 必要的分页参数设置 -->
<input type="hidden" id="TotalCount" value="@(Model != null ? Model.TotalCount : 0)" />